package com.qf.business.search.controller;

import com.qf.business.search.entity.CourseEsEntity;
import com.qf.business.search.entity.SearchParam;
import com.qf.business.search.service.ISearchService;
import com.qf.commons.base.result.R;
import com.qf.commons.base.result.Rs;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * author Ken
 * create_time 2022/12/1
 */
@RestController
@RequestMapping("/search")
@Slf4j
public class SearchController {

    @Autowired
    private ISearchService searchService;

    //@RequestParam 表单的数据和地址栏？后的传参可以用这个注解获取 ?a[]=1
    @RequestMapping("/courseSearch")
    public R courseSearch(SearchParam searchParam){
        log.debug("[search course] 进行课程搜索 - {}", searchParam);
        List<CourseEsEntity> result = searchService.search(searchParam);
        return Rs.create(result);
    }
}
